package com.teaclipse.presentation;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ListModel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.JMenuItem;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import com.teaclipse.presentation.editorKit.TeaEditorKit;

import java.awt.Color;
import java.awt.Component;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Observable;
import javax.swing.JTable;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import javax.swing.JApplet;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;

public class TeaEditorGUI extends JFrame implements IManagedWindow,
        IManagedConsoleWindow, IManagedCompilerProblemsWindow {
   public JFrame frame = new JFrame();
    private JMenuBar teaJMenuBar = null;
    private JMenu fileMenu = null;
    private JMenu runMenu = null;
    private JMenu aboutMenu = null;
    private JSplitPane teaSplitPane = null;
    private JSplitPane teaDocumentSplitPane = null;
    private JList teaDocumentList = null;
    private JScrollPane teaDocumentScrollPane = null;
    private JMenuItem newMenuItem = null;
    private TeaEditorGUI thisReference = null;
    private ArrayList windowIdList = new ArrayList();
    private JMenuItem openMenuItem = null;
    private JMenuItem saveMenuItem = null;
    private JMenuItem closeMenuItem = null;
    private JMenuItem saveAsMenuItem = null;
    private JMenuItem exitMenuItem = null;
    private JMenuItem makeMenuItem = null;
    private JMenuItem runMenuItem = null;
    private JSplitPane teaSubSplitPane = null;
    private JTabbedPane jTabbedPane = null;
    private JScrollPane jTextPane = null;
    private JTextPane teaProblemsTextPane1 = null;
    private JScrollPane teaConsoleScrollPane = null;
    private JTextPane teaConsoleTextPane1 = null;
    private JSplitPane teaBottomSplitPane = null;
    private JToolBar jToolBar = null;
    private JProgressBar teaProgressBar = null;
    private JTextField teaCursorLocationTextField = null;
    /**
     * This method initializes
     *
     */
    public TeaEditorGUI() {
        super();
        initialize();
        thisReference = this;
    }

  public void init()
  {
      this.setVisible(true);

  }

    /**
     * This method initializes this
     *
     */
    private void initialize() {
        this.setTitle("Tea-Clipse");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setBounds(new java.awt.Rectangle(0, 0, 928, 800));
        this.setContentPane(getTeaSplitPane());
        this.setJMenuBar(getTeaJMenuBar());
     
    }

    /**
     *
     *
     */
    public void createNewDocument(String documentName) {
        teaDocumentScrollPane.getViewport().add(TeaEditorKit.
                                                CreateTeaEditorPane());
    }

    /**
     * This method initializes teaJMenuBar
     *
     * @return javax.swing.JMenuBar
     */
    private JMenuBar getTeaJMenuBar() {
        if (teaJMenuBar == null) {
            teaJMenuBar = new JMenuBar();
            teaJMenuBar.add(getFileMenu());
            teaJMenuBar.add(getRunMenu());
            teaJMenuBar.add(getAboutMenu());
        }
        return teaJMenuBar;
    }

    /**
     * This method initializes fileMenu
     *
     * @return javax.swing.JMenu
     */
    private JMenu getFileMenu() {
        if (fileMenu == null) {
            fileMenu = new JMenu();
            fileMenu.setText("File");
            fileMenu.add(getNewMenuItem());
            fileMenu.add(getOpenMenuItem());
            fileMenu.addSeparator();
            fileMenu.add(getSaveMenuItem());
            fileMenu.add(getSaveAsMenuItem());
            fileMenu.addSeparator();
            fileMenu.add(getCloseMenuItem());
            fileMenu.addSeparator();
            fileMenu.add(getExitMenuItem());

        }
        return fileMenu;
    }

    /**
     * This method initializes runMenu
     *
     * @return javax.swing.JMenu
     */
    private JMenu getRunMenu() {
        if (runMenu == null) {
            runMenu = new JMenu();
            runMenu.setText("Run");
            runMenu.add(getMakeMenuItem());
           // runMenu.add(getRunMenuItem());
        }
        return runMenu;
    }

    /**
     * This method initializes aboutMenu
     *
     * @return javax.swing.JMenu
     */
    private JMenu getAboutMenu() {
        if (aboutMenu == null) {
            aboutMenu = new JMenu();
            aboutMenu.setText("Help");
            aboutMenu.setHorizontalTextPosition(javax.swing.SwingConstants.
                                                TRAILING);
            JMenuItem noHelp = new JMenuItem();
            noHelp.setText("There isn't any...");
            aboutMenu.add(noHelp);
        }
        return aboutMenu;
    }

    /**
     * This method initializes teaSplitPane
     *
     * @return javax.swing.JSplitPane
     */
    private JSplitPane getTeaSplitPane() {
        if (teaSplitPane == null) {
            teaSplitPane = new JSplitPane();
            teaSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
            teaSplitPane.setDividerSize(5);
            teaSplitPane.setTopComponent(getTeaDocumentSplitPane());
            teaSplitPane.setDividerLocation(450);
            teaSplitPane.setEnabled(false);
            teaSplitPane.setBottomComponent(getTeaSubSplitPane());
        }
        return teaSplitPane;
    }

    /**
     * This method initializes teaDocumentSplitPane
     *
     * @return javax.swing.JSplitPane
     */
    private JSplitPane getTeaDocumentSplitPane() {
        if (teaDocumentSplitPane == null) {
            teaDocumentSplitPane = new JSplitPane();
            teaDocumentSplitPane.setDividerSize(5);
            teaDocumentSplitPane.setEnabled(true);
            teaDocumentSplitPane.setLeftComponent(getTeaDocumentList());
            teaDocumentSplitPane.setRightComponent(getTeaDocumentScrollPane());
            teaDocumentSplitPane.setDividerLocation(150);
        }
        return teaDocumentSplitPane;
    }

    /**
     * This method initializes teaDocumentList
     *
     * @return javax.swing.JList
     */
    private JList getTeaDocumentList() {
        if (teaDocumentList == null) {
            teaDocumentList = new JList();
            teaDocumentList.setCellRenderer(new TeaCellRenderer());
            teaDocumentList.addListSelectionListener(new
                    TeaListSelectionListener());
        }
        return teaDocumentList;
    }

    /**
     * This method initializes teaDocumentScrollPane
     *
     * @return javax.swing.JScrollPane
     */
    private JScrollPane getTeaDocumentScrollPane() {
        if (teaDocumentScrollPane == null) {
            teaDocumentScrollPane = new JScrollPane();
        }
        return teaDocumentScrollPane;
    }

    /**
     * This method initializes newMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getNewMenuItem() {
        if (newMenuItem == null) {
            newMenuItem = new JMenuItem();
            newMenuItem.setText("New");
            newMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                   // System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()

                    TeaWindowManager.newDocument();

                }
            });
        }
        return newMenuItem;
    }

    /**
     * Method from IManagedWindow Interface
     * @param window Object
     */
    public void switchWindow(Object window) {
        //System.out.println("SWITCHING WINDOW");
        teaDocumentScrollPane.getViewport().removeAll();
        teaDocumentScrollPane.getViewport().add((JEditorPane) window);
    }

    /**
     * Method from IManagedWindow interface
     * @param windowName String
     * @param windowId Object
     * @return Object
     */
    public Object createWindow(String windowName, Object windowId) {
        /* creates a new editor kit and adds it to the scroll pane
           view port*/
        JEditorPane newEditorKit = TeaEditorKit.CreateTeaEditorPane();
        LineNumbers ln = new LineNumbers(newEditorKit);
        teaDocumentScrollPane.setRowHeaderView(ln);

        teaDocumentScrollPane.getViewport().add(newEditorKit);

        /* get the list model and add this document to the list model */
        ListModel teaListModel = teaDocumentList.getModel();
        int size = teaListModel.getSize();

        Object[] data = new Object[size + 1];

        int i = 0;
        for (i = 0; i < size; i++) {
            data[i] = teaListModel.getElementAt(i).toString();
        }

        windowIdList.add(i, windowId);
        TeaListObjectStruct tlo = new TeaListObjectStruct(windowId.toString(),
                windowName);
        data[i] = tlo;

        teaDocumentList.setListData(data);
        teaDocumentList.setSelectedIndex(i);
        return newEditorKit;
    }

    /**
     * Inner class to renderer the list cells
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2006</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    class TeaCellRenderer extends JLabel implements ListCellRenderer {

        // This is the only method defined by ListCellRenderer.
        // We just reconfigure the JLabel each time we're called.

        public Component getListCellRendererComponent(
                JList list,
                Object value, // value to display
                int index, // cell index
                boolean isSelected, // is the cell selected
                boolean cellHasFocus) { // the list and the cell have the focus
            String s = value.toString();
            setText(s);
            //setIcon(new ImageIcon(TeaGUIConstants.IMAGE_PATH + "fileIcon.jpg"));
            //setIcon((s.length() > 10) ? longIcon : shortIcon);
            if (isSelected) {
                setBackground(Color.RED);
                setForeground(Color.MAGENTA);

            } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            }
            setEnabled(list.isEnabled());
            setFont(list.getFont());
            return this;
        }
    }


    /**
     * inner class to make an object for the list model
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2006</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    class TeaListObjectStruct {
        public String id = "";
        public String name = "";

        public TeaListObjectStruct(String id, String name) {
            this.id = id;
            this.name = name;
        }

        public String toString() {
            int lastIndex = name.lastIndexOf("\\");
            String returnValue = "";

            if (lastIndex != -1) {
                returnValue = name.substring(lastIndex + 1);
            } else {
                returnValue = getName();
            }

            return returnValue;
        }

        public String getName() {
            return name;
        }

        public String getId() {
            return id;
        }
    }


    /**
     * Listener for selections
     * <p>Title: </p>
     *
     * <p>Description: </p>
     *
     * <p>Copyright: Copyright (c) 2006</p>
     *
     * <p>Company: </p>
     *
     * @author not attributable
     * @version 1.0
     */
    class TeaListSelectionListener implements ListSelectionListener {

        public void valueChanged(ListSelectionEvent e) {
            try {
                JList listObject = (JList) e.getSource();
                int index = listObject.getSelectedIndex();

                if (index != -1) {
                    String windowId = (String) windowIdList.get(index);

                    if (windowId != null) {

                        //System.out.println(windowId);
                        TeaWindowManager.switchDocument(windowId);
                    } else {
                        System.out.println(
                                "TeaListSelectionListener: windowId is null");
                    }
                }
            } catch (Exception ex) {

            }
        }
    }


    /**
     * This method initializes openMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getOpenMenuItem() {
        if (openMenuItem == null) {
            openMenuItem = new JMenuItem();
            openMenuItem.setText("Open");
            openMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    //System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()

                    openNewDocument();
                }
            });
        }
        return openMenuItem;
    }

    /**
     * opens a new document
     */
    public void openNewDocument() {
        TeaFileChooser fileChooser = new TeaFileChooser();
        int value = fileChooser.showOpenDialog(thisReference);
        if (value == JFileChooser.APPROVE_OPTION) {
            try {
                String fileName = fileChooser.getChoosenFileName();
                TeaWindowManager.open(fileName);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    /**
     * Executes a 'save as' on the document
     * @return boolean
     */
    public boolean saveAsDocument() {
        boolean returnValue = false;

        /* create a file chooser object and get the filename if
           one is chosen*/
        TeaFileChooser fileChooser = new TeaFileChooser();

        /* find out if a valid name is chosen*/
        int value = fileChooser.showSaveDialog(thisReference);

        //System.out.println("value = " + value);
        String fileName = "";

        try {
            if (value == 0) {

                /* get the chosen file */
                fileName = fileChooser.getChoosenFileName();
                //System.out.println("The fileName is " + fileName);

                /* call the controller to execute the save as*/
                TeaWindowManager.saveAs(fileName);
                returnValue = true;
            }
        } catch (Exception ex) {
            System.out.println("error saving file" + fileName);
        }

        return returnValue;
    }


    /** Fills the contents of the window with the contents (IManagedWindow method)
     * Method from IManagedWindow
     * @param window Object
     * @param contents Object
     */
    public void fillContents(Object window, Object contents) {

        //System.out.println("opening file" + contents.toString());
        File file = new File(contents.toString());
        try {
            ((JEditorPane) window).read(new FileReader(file), file);
        } catch (Exception ex) {
            System.out.println("error reading file" + contents.toString());
        }

    }

    /**
     * overwritten IManagedWindow method
     * @param window Object
     * @param windowId Object
     */
    public void deleteWindow(Object window, Object windowId) {
        teaDocumentScrollPane.getViewport().removeAll();
        teaDocumentScrollPane.invalidate();
        this.repaint();
        removefromDocumentList(windowId);


    }

    /**
     * removes a document from the documentList
     * @param windowId Object
     */
    private void removefromDocumentList(Object windowId) {
        /* get the index of the window*/
        int index = windowIdList.indexOf(windowId);

        /* if there is a valid index, remove it from
           the document list widget */
        if (index != -1) {
            /* get the list model and the data*/
            ListModel listModel = teaDocumentList.getModel();
            int size = listModel.getSize();

            Object[] newData = new Object[size - 1];
            int currentIndex = 0;

            /* compile the new data*/
            for (int i = 0; i < size; i++) {
                if (i != index) {
                    newData[currentIndex++] = listModel.getElementAt(i).toString();
                }
            }

            windowIdList.remove(index);

            /* set the document list with the data and set
               the first index selected by default - this will
               trigger a document switch*/
            teaDocumentList.setListData(newData);
            teaDocumentList.setSelectedIndex(0);

            if(windowIdList != null && windowIdList.size() > 0)
            {

                TeaWindowManager.switchDocument((String) windowIdList.get(0));
            }
        }
    }

    /**
     * This method initializes saveMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getSaveMenuItem() {
        if (saveMenuItem == null) {
            saveMenuItem = new JMenuItem();
            saveMenuItem.setText("Save");
           // saveMenuItem.setIcon(new ImageIcon(TeaGUIConstants.IMAGE_PATH +
            //                                   "saveIcon.gif"));
            saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    //System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()

                    /* if the current window is a new window then
                       we have to do a save-as..otherwise just do a
                       save through the controller*/
                    if (TeaWindowManager.isCurrentWindowNew()) {
                        //System.out.println("THIS SCREEN IS NEW - do save as");
                        thisReference.saveAsDocument();
                    } else {
                        TeaWindowManager.save();
                    }
                }
            });
        }
        return saveMenuItem;
    }

    /**
     * Writes the contents of the window to the contents
     * @param window Object
     * @param contents Object
     */
    public void writeContents(Object window, Object contents) {
        // TODO Auto-generated method stub
        try {
            ((JEditorPane) window).write(new FileWriter(new File(contents.
                    toString())));

        } catch (Exception ex) {
            System.out.println("Error writing to file: " + contents.toString());
        }
    }

    /**
     * This method initializes closeMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getCloseMenuItem() {
        if (closeMenuItem == null) {
            closeMenuItem = new JMenuItem();
            closeMenuItem.setText("Close");
            closeMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                   // System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
                    TeaWindowManager.close();
                }
            });
        }
        return closeMenuItem;
    }

    /**
     * This method initializes saveAsMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getSaveAsMenuItem() {
        if (saveAsMenuItem == null) {
            saveAsMenuItem = new JMenuItem();
            saveAsMenuItem.setText("Save As");
//            saveAsMenuItem.setIcon(new ImageIcon(TeaGUIConstants.IMAGE_PATH +
  //                                               "saveAsIcon.gif"));
            saveAsMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    //System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()

                    thisReference.saveAsDocument();
                }
            });
        }
        return saveAsMenuItem;
    }

    /**
     * This method initializes exitMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getExitMenuItem() {
        if (exitMenuItem == null) {
            exitMenuItem = new JMenuItem();
            exitMenuItem.setText("Exit");
            exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    //System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
                    System.exit(0);
                }
            });
        }
        return exitMenuItem;
    }

    /**
     * This method initializes makeMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getMakeMenuItem() {
        if (makeMenuItem == null) {
            makeMenuItem = new JMenuItem();
            makeMenuItem.setText("Run");
//            makeMenuItem.setIcon(new ImageIcon(TeaGUIConstants.IMAGE_PATH +
  //                                             "buildIcon.gif"));
            makeMenuItem.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    //System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
                    boolean compile = false;
                    thisReference.teaProgressBar.setValue(0);
                    if (TeaWindowManager.isCurrentWindowNew()) {
                        boolean successful = saveAsDocument();
                        if (successful) {
                            compile = true;
                        }
                    } else {
                        compile = true;
                        TeaWindowManager.save();
                    }

                    if (compile) {
                        clearOutputWindows();
                        thisReference.teaProgressBar.setValue(50);
                        TeaWindowManager.compile();
                        thisReference.teaProgressBar.setValue(100);
                        reportCompileOK();
                    }

                }
            });

        }
        return makeMenuItem;
    }

    private void reportCompileOK() {
        if (this.teaProblemsTextPane1.getText().equals("")) {
            this.teaProblemsTextPane1.setText(
                    "Compilation Successful...see console for results");
        }
        thisReference.teaProgressBar.setValue(0);
    }

    private void clearOutputWindows() {
        this.teaProblemsTextPane1.setText("");
        this.teaConsoleTextPane1.setText("");
    }

    /**
     * This method initializes runMenuItem
     *
     * @return javax.swing.JMenuItem
     */
    private JMenuItem getRunMenuItem() {
        if (runMenuItem == null) {
            runMenuItem = new JMenuItem();
            runMenuItem.setText("Run...");
//            runMenuItem.setIcon(new ImageIcon(TeaGUIConstants.IMAGE_PATH +
  //                                            "saveIcon.gif"));

        }
        return runMenuItem;
    }

    /**
     * This method initializes teaSubSplitPane
     *
     * @return javax.swing.JSplitPane
     */
    private JSplitPane getTeaSubSplitPane() {
        if (teaSubSplitPane == null) {
            teaSubSplitPane = new JSplitPane();
            teaSubSplitPane.setOrientation(javax.swing.JSplitPane.
                                           VERTICAL_SPLIT);
            teaSubSplitPane.setDividerLocation(250);
            teaSubSplitPane.setEnabled(false);
            teaSubSplitPane.setDividerSize(1);
            teaSubSplitPane.setBottomComponent(getTeaBottomSplitPane());
            teaSubSplitPane.setTopComponent(getJTabbedPane());
        }
        return teaSubSplitPane;
    }

    /**
     * This method initializes jTabbedPane
     *
     * @return javax.swing.JTabbedPane
     */
    private JTabbedPane getJTabbedPane() {
        if (jTabbedPane == null) {
            jTabbedPane = new JTabbedPane();
            jTabbedPane.addTab("Problems", null, getJTextPane(), null);
            jTabbedPane.addTab("Console", null, getTeaConsoleScrollPane(), null);
        }
        return jTabbedPane;
    }

    /**
     * This method initializes jTextPane
     *
     * @return javax.swing.JScrollPane
     */
    private JScrollPane getJTextPane() {
        if (jTextPane == null) {
            jTextPane = new JScrollPane();
            jTextPane.setEnabled(false);
            jTextPane.setViewportView(getTeaProblemsTextPane1());
        }
        return jTextPane;
    }

    /**
     * This method initializes teaTextPane1
     *
     * @return javax.swing.JTextPane
     */
    private JTextPane getTeaProblemsTextPane1() {
        if (teaProblemsTextPane1 == null) {
            teaProblemsTextPane1 = new JTextPane();
            System.setErr(new CompilerProblemFrame(System.err,
                    teaProblemsTextPane1));
        }
        return teaProblemsTextPane1;
    }

    /**
     * This method initializes teaConsoleScrollPane
     *
     * @return javax.swing.JScrollPane
     */
    private JScrollPane getTeaConsoleScrollPane() {
        if (teaConsoleScrollPane == null) {
            teaConsoleScrollPane = new JScrollPane();
            teaConsoleScrollPane.setViewportView(getTeaConsoleTextPane1());
        }
        return teaConsoleScrollPane;
    }

    /**
     * This method initializes teaConsoleTextPane1
     *
     * @return javax.swing.JTextPane
     */
    private JTextPane getTeaConsoleTextPane1() {
        if (teaConsoleTextPane1 == null) {
            teaConsoleTextPane1 = new JTextPane();
            System.setOut(new CompilerConsoleFrame(System.out,
                    teaConsoleTextPane1));
        }
        return teaConsoleTextPane1;
    }

    /**
     * This method initializes teaBottomSplitPane
     *
     * @return javax.swing.JSplitPane
     */
    private JSplitPane getTeaBottomSplitPane() {
        if (teaBottomSplitPane == null) {
            teaBottomSplitPane = new JSplitPane();
            teaBottomSplitPane.setDividerSize(1);
            teaBottomSplitPane.setLeftComponent(getJToolBar());
            teaBottomSplitPane.setRightComponent(getTeaCursorLocationTextField());
            teaBottomSplitPane.setDividerLocation(850);
        }
        return teaBottomSplitPane;
    }

    /**
     * This method initializes jToolBar
     *
     * @return javax.swing.JToolBar
     */
    private JToolBar getJToolBar() {
        if (jToolBar == null) {
            jToolBar = new JToolBar();
            jToolBar.add(getJProgressBar());
        }
        return jToolBar;
    }

    /**
     * This method initializes jProgressBar
     *
     * @return javax.swing.JProgressBar
     */
    private JProgressBar getJProgressBar() {
        if (teaProgressBar == null) {
            teaProgressBar = new JProgressBar();
        }
        return teaProgressBar;
    }

    /**
     * This method initializes teaCursorLocationTextField
     *
     * @return javax.swing.JTextField
     */
    private JTextField getTeaCursorLocationTextField() {
        if (teaCursorLocationTextField == null) {
            teaCursorLocationTextField = new JTextField();
        }
        return teaCursorLocationTextField;
    }
} //  @jve:decl-index=0:visual-constraint="10,10"
